package cn.edu.zafu.camera;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ContNum4CaMan {
	static Map<String, List<String>> z1 = new HashMap<String, List<String>>();
	static Map<String, List<String>> z2 = new HashMap<String, List<String>>();
	static Map<String, List<String>> z3 = new HashMap<String, List<String>>();
	static Map<String, List<String>> z4 = new HashMap<String, List<String>>();
	static Map<String, Object> rep = new HashMap<String, Object>();

	String str = " APLU, APSU,HJLU, HJCU,HYNU, HYGU,ZIMU, ZCSU,YMLU, YMGU,CMAU, CMCU,KKFU, KKTU, KLFU, KLTU,HPLU,CCLU, CSLU,KMTU,NYKU,"
			+ "WHLU, LTLU, NORU, PILU, RCLU, CNCU, FESU, AMFU, BHCU, CLHU, CRLU, CAXU, IKKU, INTU, IRNU, CRXU, HNPU, IATU, ICSZ,"
			+ "IEAU, INNU, ITLU, LPIU, FFFZ, FLXZ, FVIC, UFCC, SKIZ, XTRC, FLGZ, ZMFC, XNPZ, XDAZ, XNOZ, GCEZ, FBLU, FSCU, GATU, APLS,"
			+ "CBFU, CLOU, CTIU, DVRU, ECMU, EMAU, GCEG, GSTU, ICCU, ITLS, LYKU, MAEU, SCCU, SCDC, SCPU, SCXU, SCZU, SCZY, SENU,"
			+ "SPLU, SSIU, STBU, UFCU, WCSU, XTRU, GOLD, GLDU, GRDU, SLMU, TECU, ANYU, LSEU, MLCU, PRSU, TEXU, TGHU, WCIU,"
			+ "CRMU, GCEU, TRAC, INBU, IPXU,IRSZ, MTYU, TAXZ, TRZZ, ICSU, NSIU, TOLU, TPHU, TRLU, TRZU, TRIU, TTNU, UXXU, UESU,"
			+ "EASU, WFHU, XTCZ, GEXU,TEMU,HLXU,FCIU,SNSU,DFSU";

//	public static void main(String[] args) {
//
//		// System.out.println(str);S
//		str = str.replace(" ", "");
//		String[] strs = str.split(",");
//		for (int i = 0; i < strs.length; i++) {
//			hasRepeated(strs[i]);
//			/*oneZ2Map(z1,strs[i],0,1);
//			oneZ2Map(z2,strs[i],1,2);
//			oneZ2Map(z3,strs[i],2,3);
//			oneZ2Map(z4,strs[i],3,4);*/
//
//			threeZ2Map(z1, strs[i], 0, 2);
//			threeZ2Map(z1, strs[i], 1, 3);
//			threeZ2Map(z1, strs[i], 2, 4);
//			threeZ2Map(z3, strs[i], 0, 3);
//			threeZ2Map(z3, strs[i], 1, 4);
//		}
//		printMapResult2(z1, "前后两位");
//		printMapResult2(z3, "前后三位");
///*		printMapResult1(z1, 1);
//		printMapResult1(z2, 2);
//		printMapResult1(z3, 3);
//		printMapResult1(z4, 4);*/
//	}

	public static void doSave(){
		String str = " APLU, APSU,HJLU, HJCU,HYNU, HYGU,ZIMU, ZCSU,YMLU, YMGU,CMAU, CMCU,KKFU, KKTU, KLFU, KLTU,HPLU,CCLU, CSLU,KMTU,NYKU,"
				+ "WHLU, LTLU, NORU, PILU, RCLU, CNCU, FESU, AMFU, BHCU, CLHU, CRLU, CAXU, IKKU, INTU, IRNU, CRXU, HNPU, IATU, ICSZ,"
				+ "IEAU, INNU, ITLU, LPIU, FFFZ, FLXZ, FVIC, UFCC, SKIZ, XTRC, FLGZ, ZMFC, XNPZ, XDAZ, XNOZ, GCEZ, FBLU, FSCU, GATU, APLS,"
				+ "CBFU, CLOU, CTIU, DVRU, ECMU, EMAU, GCEG, GSTU, ICCU, ITLS, LYKU, MAEU, SCCU, SCDC, SCPU, SCXU, SCZU, SCZY, SENU,"
				+ "SPLU, SSIU, STBU, UFCU, WCSU, XTRU, GOLD, GLDU, GRDU, SLMU, TECU, ANYU, LSEU, MLCU, PRSU, TEXU, TGHU, WCIU,"
				+ "CRMU, GCEU, TRAC, INBU, IPXU,IRSZ, MTYU, TAXZ, TRZZ, ICSU, NSIU, TOLU, TPHU, TRLU, TRZU, TRIU, TTNU, UXXU, UESU,"
				+ "EASU, WFHU, XTCZ, GEXU,TEMU";
		 System.out.println(str);
		str = str.replace(" ", "");
		String[] strs = str.split(",");
		for (int i = 0; i < strs.length; i++) {
			hasRepeated(strs[i]);
			/*oneZ2Map(z1,strs[i],0,1);
			oneZ2Map(z2,strs[i],1,2);
			oneZ2Map(z3,strs[i],2,3);
			oneZ2Map(z4,strs[i],3,4);*/

			threeZ2Map(z1, strs[i], 0, 2);
			threeZ2Map(z1, strs[i], 1, 3);
			threeZ2Map(z1, strs[i], 2, 4);
		}
		printMapResult2(z1, "前后两位");
/*		printMapResult1(z1, 1);
		printMapResult1(z2, 2);
		printMapResult1(z3, 3);
		printMapResult1(z4, 4);*/
	}

	/**
	 * 是否有重复
	 * 
	 * @param str
	 */
	public static void hasRepeated(String str) {
		if (!rep.containsKey(str)) {
			rep.put(str, null);
		} else {
			System.out.println("重复数据=" + str);
		}
	}

	/**
	 * 相同位置上相同字母的封装入List
	 * @param z
	 * @param str
	 * @param start
	 * @param end
	 */
	public static void oneZ2Map(Map<String, List<String>> z , String str,int start,int end) {
		String s = str.substring(start, end);
		if (!z.containsKey(s)) {
			List<String> cont4z = new ArrayList();
			cont4z.add(str);
			z.put(s, cont4z);
		} else {
			z.get(s).add(str);
		}
	}
	
	/**
	 * 将三位字母封装入map list
	 * @param z
	 * @param str
	 * @param start
	 * @param end
	 */
	public static void threeZ2Map(Map<String, List<String>> z , String str,int start,int end) {
		String s = str.substring(start, end);
		if (!z.containsKey(s)) {
			List<String> cont4z = new ArrayList();
			cont4z.add(str);
			z.put(s, cont4z);
		} else {
			z.get(s).add(str);
		}
	}
	
	/**
	 * 报告一
	 * @param z
	 * @param i
	 */
	public static void printMapResult1(Map<String,List<String>> z,int i)
	{
		System.out.println("-----------------------"+"第"+i +"字母一共有"+z.size()  +  "种 ----------------------");
		for(String key : z.keySet())
		{
			System.out.print("第"+i +"字母为: " + key + " 的,一共有 " + z.get(key).size() + " 个,分别是: ");
			for(String value : z.get(key))
			{
				System.out.print(value + " ");
			}
			System.out.println();
		}
		
	}
	/**
	 * 报告二
	 * @param z
	 * @param //i
	 */
	public static void printMapResult2(Map<String,List<String>> z,String remark)
	{
		System.out.println("-----------------------"+ remark +  "----------------------");
		for(String key : z.keySet())
		{
			System.out.print("字母为: " + key + " 的,一共有 " + z.get(key).size() + " 个,分别是: ");
			for(String value : z.get(key))
			{

				HeadChar headChar =new HeadChar();
				headChar.setHeadKey(key);
				headChar.setHeadChar(value);
				HeadCharUtil.saveHeadChar(headChar);
				System.out.print(value + " ");
			}
			System.out.println();
		}
		
	}
}
